﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using Toon.Controls;
using Toon.Models.Catalogs;
using Toon.Models.Characters;
using System.Windows.Controls;

namespace Toon.Dialogs
{
	public partial class ShitckPicker : ImprovedChildWindow
	{
		public ShitckPicker()
		{
			this.AddCommand<ShitckDefinition>("AddShitck", v => TypedDataContext.Shitcks.Add(v));
			this.AddCommand("NewShitck", v => TypedDataContext.Shitcks.AddNew());
			this.AddCommand<Shitck>("RemoveShitck", v => TypedDataContext.Shitcks.Remove(v));
			this.AddCommand<Shitck>("PlusCommand", p => p.TweakPoints += 1);
			this.AddCommand<Shitck>("MinusCommand", p => p.TweakPoints -= 1);
			this.AddConverter<int, Visibility>("MinusVisibility", value => value <= 0 ? Visibility.Collapsed : Visibility.Visible);

			InitializeComponent();
		}

		private void OKButton_Click(object sender, RoutedEventArgs e)
		{
			DialogResult = true;
		}

		public static ShitckPicker Show(Control owner, Character character)
		{
			var dlg = new ShitckPicker();
			dlg.DataContext = character;
			dlg.Show(owner);

			return dlg;
		}

		public Character TypedDataContext
		{
			get { return (Character)DataContext; }
		}


	}
}

